<template>
  <div ref="div" style="height: 50px"></div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  data() {
    return {
      myEchart: null,
      source: [{ x: 78, y: 0 }]
    }
  },
  methods: {
    drawImg() {
      this.myEchart.setOption({
        dataset: {
          source: this.source
        },
        grid: {
          top: 0,
          left: 0,
          right: 0,
          bottom: 0
        },
        xAxis: {
          min: 0,
          max: 100,
          show: false
        },
        yAxis: {
          show: false,
          type: 'category'
        },
        series: [
          {
            name: '',
            type: 'bar',
            barWidth: 10,
            encode: {
              x: 'x',
              y: 'y'
            },
            showBackground: true,
            backgroundStyle: { color: '#eee' },
            label: {
              show: true,
              formatter: '|',
              position: 'right'
            },
           itemStyle:{
            color:'green'
           }
          }
        ]
      })
    }
  },
  mounted() {
    this.myEchart = echarts.init(this.$refs.div)
    this.drawImg()
  }
}
</script>

<style></style>
